<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>05-跑马灯</title>
</head>
<body>
  <div id="app">
    <h1>vue的例子</h1>
    <p>{{msg}}</p>
    <h2>{{str}}</h2>
    <input type="button" value="开始" @click="start">
    <input type="button" value="停止" @click="stop">
  </div>
  <script src="../js/vue.js"></script>
  <script>
    Vue.config.productionTip = false; // 关闭生产提示
    const vm = new Vue({
      el: '#app',
      data: {
        msg: 'hello',
        str: '年龄人为什么没有钱?因为找到工作了要大吃一顿，失业也要大吃一顿，好几天没有吃好的了，也要大吃一顿',
        timeId: null
      },
      methods: {
        start() {
          clearInterval(this.timeId)
          this.timeId = setInterval(() => {
            this.str = this.str.slice(1) + this.str.slice(0, 1)
          }, 300)
        },
        stop() {
          clearInterval(this.timeId)
        }
      }
    })
  </script>
</body>
</html>